package com.student.controller;

import com.student.dto.ResponseDto;
import com.student.service.SnackCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: makeups
 * @BelongsPackage: com.student.controller
 * @Author: 小徐
 * @CreateTime: 2024-12-22 23:43
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("card")
public class SnackCardController {
    @Autowired
    private SnackCardService snackCardService;


    //      添加购物车
    @RequestMapping("addCard")
    public ResponseDto addCard(@RequestParam("UserId") Integer userId, @RequestParam("goodId") Integer goodId,
                               @RequestParam("num") Integer num) {

        return snackCardService.addCard(userId, goodId, num);
    }

    //   获取用户的订单数量
    @RequestMapping("getAllCard")
    public ResponseDto getAllCard(@RequestParam("UserId") Integer userId) {
        return snackCardService.getAllCard(userId);
    }

    // 这边做数量的变化
    @RequestMapping("addNumber")
    public ResponseDto addNumber(@RequestParam("id") Integer id, @RequestParam("number") Integer number) {
        return snackCardService.addNumber(id, number);
    }

}